package com.dayaokeji.rhythmschoolstudent.client.common

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.dayaokeji.rhythmschoolstudent.R
import com.dayaokeji.rhythmschoolstudent.client.common.base.ActivityTemplateMethod
import com.dayaokeji.rhythmschoolstudent.client.common.base.common.BaseActivity
import kotlinx.android.synthetic.main.activity_submit_state_final.*
import java.io.Serializable

/**
 * 提交状态最终页面
 */
class SubmitStateFinalActivity : BaseActivity() , ActivityTemplateMethod{

    companion object {
        private const val STATE = "submit_state"
        enum class State : Serializable{
            SUCCESS,
            FAILURE
        }

        fun navigation(context: Context,state: State) {
            val intent = Intent(context, SubmitStateFinalActivity::class.java)
            intent.putExtra(STATE,state)
            context.startActivity(intent)
        }
    }

    private lateinit var state: State

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_submit_state_final)
        toolbar?.let {
            setSupportActionBar(it)
        }
        init()
    }

    override fun init() {
        super.init()
        state = intent.getSerializableExtra(STATE) as State
    }

    override fun setupView() {
        when (state) {
            State.SUCCESS -> {
                ivSubmitState.setImageResource(R.mipmap.bg_submit_success)
                tvSubmitStateInfo.text = "提交成功"
            }
            State.FAILURE -> {
                ivSubmitState.setImageResource(R.mipmap.bg_submit_failure)
                tvSubmitStateInfo.text = "提交失败"
            }
        }
    }

    override fun setupViewData() {
    }
}
